package com.easygoods.bean;


import com.bestvike.stone.spring.exception.AssertUtils;
import lombok.Data;

import java.math.BigDecimal;

/**
 * @author zhq
 * @date 2019/1/20
 */
@Data
public class OrderBean {
    private String merchantId;
    private int itemCount;
    private int pointValue;
    private BigDecimal totalOrderAmount;
    private BigDecimal totalMemberAmount;
    private BigDecimal deliveryFee;

    public void assertValid() {
        AssertUtils.isTrue(this.totalOrderAmount != null && this.totalOrderAmount.compareTo(BigDecimal.ZERO) >= 0, "订单总金额为负数");
        AssertUtils.isTrue(this.totalMemberAmount != null && this.totalMemberAmount.compareTo(BigDecimal.ZERO) >= 0, "优惠后总金额为负数");
        AssertUtils.isTrue(this.deliveryFee != null && this.deliveryFee.compareTo(BigDecimal.ZERO) >= 0, "运费不能为负数");
    }
}
